// license-header java merge-point
/**
 * This is only generated once! It will never be overwritten.
 * You can (and have to!) safely modify it by hand.
 * TEMPLATE:    SpringServiceImpl.vsl in andromda-spring cartridge
 * MODEL CLASS: tsaditiro::com.systemsjr.tsaditiro::organisation::service::OrganisationService
 * STEREOTYPE:  Service
 */
package com.systemsjr.tsaditiro.organisation.service;

import com.systemsjr.tsaditiro.organisation.Organisation;
import com.systemsjr.tsaditiro.organisation.vo.OrganisationSearchCriteria;
import com.systemsjr.tsaditiro.organisation.vo.OrganisationVO;

import java.util.List;

/**
 * @see com.systemsjr.tsaditiro.organisation.service.OrganisationService
 */
public class OrganisationServiceImpl
    extends OrganisationServiceBase
{

    /**
     * @see com.systemsjr.tsaditiro.organisation.service.OrganisationService#loadAll()
     */
    protected  List handleLoadAll()
        throws Exception
    {
    	return (List) getOrganisationDao().toOrganisationVOCollection(getOrganisationDao().loadAll());
    }

    /**
     * @see com.systemsjr.tsaditiro.organisation.service.OrganisationService#saveUser(OrganisationVO)
     */
    protected  OrganisationVO handleSaveorganisation(OrganisationVO organisationVO)
        throws Exception
    {
    	Organisation org = getOrganisationDao().organisationVOToEntity(organisationVO);
    	
    	if(organisationVO.getId() != null){
    		getOrganisationDao().update(org);
    	} else{
    		getOrganisationDao().create(org);
    	}
    	
    	return getOrganisationDao().toOrganisationVO(org);
    }

    /**
     * @see com.systemsjr.tsaditiro.organisation.service.OrganisationService#deleteOrganisation(OrganisationVO)
     */
    protected  void handleDeleteOrganisation(OrganisationVO organisationVO)
        throws Exception
    {
    	if(organisationVO.getId() != null){
    		getOrganisationDao().remove(organisationVO.getId());
    	}
    }

    /**
     * @see com.systemsjr.tsaditiro.organisation.service.OrganisationService#searchOrganiations(OrganisationSearchCriteria)
     */
    protected  List handleSearchOrganiations(OrganisationSearchCriteria searchCriteria)
        throws Exception
    {
    	List l = getOrganisationDao().findByCriteria(searchCriteria);
    	
    	return (List) getOrganisationDao().toOrganisationVOCollection(l);
    }

}